import java.util.Date;

public class Employee implements Comparable {
    private String name;
    private int age;
    private MyDate birDate;
    public void setName(String name){
        this.name=name;
    }
    private void setAge(int age){
        this.age=age;
    }
    public void setBirhday(MyDate birDate){
        this.setAge(new Date().getYear()+1900-birDate.getYear());
        this.birDate=birDate;
    }
    public String getName(){
        return this.name;
    }
    public int getAge(){
        return this.age;
    }
    public MyDate getBirDate(){
        return this.birDate;
    }
    public Employee(String name,int age,MyDate birDate) throws Exception{
        this.setName(name);
        this.setBirhday(birDate);
        if(this.age!=age) throw new Exception("年龄不对");
    }
    @Override
    public String toString() {
        return "姓名："+this.name+" 年龄："+this.age+" 出生日期："+this.birDate.getYear()+"年"+this.birDate.getMonth()+"月"+this.birDate.getDay()+"日";
    }
    @Override
    public int compareTo(Object o) {
        if(o instanceof Employee){
            Employee other=(Employee) o;
            return this.name.compareTo(other.name.toString());
        }
        return 0;
    }
}
